﻿<phone:PhoneApplicationPage 
    x:Class="Stopwatch.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
    xmlns:swControls="clr-namespace:Stopwatch.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    OrientationChanged="PhoneApplicationPage_OrientationChanged" 
    toolkit:TiltEffect.IsTiltEnabled="True">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="PivotHeader" TargetType="TextBlock">
            <Setter Property="FontSize" Value="22" />
            <Setter Property="FontFamily" Value="Segoe WP Bold" />
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--枢轴控件-->
        <controls:Pivot>
            <!--枢轴项一-->
            <controls:PivotItem>
                <controls:PivotItem.Header>
                    <TextBlock Text="STOPWATCH" Style="{StaticResource PivotHeader}"/>
                </controls:PivotItem.Header>
                <Grid Width="450">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="200" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="200" />
                    </Grid.RowDefinitions>
                    <swControls:StopwatchControl Grid.Row="0" x:Name="stopwatchControl" HorizontalAlignment="Center" />
                    <ScrollViewer Grid.Row="1" x:Name="StopedItemScrollViewer" Width="380" Height="190" HorizontalAlignment="Center">
                        <ItemsControl x:Name="stoplist">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100"/>
                                            <ColumnDefinition Width="160"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Grid.Column="0" HorizontalAlignment="Left" Margin="5,0,0,0" Text="{Binding Order}" Foreground="{StaticResource PhoneSubtleBrush}"  FontSize="28"/>
                                        <TextBlock Grid.Column="1" Text="{Binding StopedTime}" Foreground="{StaticResource PhoneAccentBrush}" FontSize="28" />
                                        <TextBlock Grid.Column="2" HorizontalAlignment="Right" Margin="0,0,5,0" Text="{Binding OriginalTime}" Foreground="{StaticResource PhoneSubtleBrush}" FontSize="28" />
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                    <Grid x:Name="ContentPanel2" Grid.Row="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="StopwatchReset" Grid.Column="1" Margin="8" Content="reset" VerticalAlignment="Bottom" Template="{StaticResource resetButton}" Click="StopwatchResetOnClick" IsEnabled="False"/>
                        <Button x:Name="StopwatchStart" Grid.Column="2" Margin="5" Content="start" VerticalAlignment="Bottom" Template="{StaticResource startButton}" Click="StopwatchStartOnClick" />
                        <Button x:Name="StopwatchPause" Grid.Column="2" Margin="5" Content="pause" VerticalAlignment="Bottom" Template="{StaticResource pauseButton}" Click="StopwatchStartOnClick" Visibility="Collapsed" />
                        <Button x:Name="StopwatchAdd" Grid.Column="3" Margin="8" Content="add" VerticalAlignment="Bottom" Template="{StaticResource addButton}" Click="StopwatchAddOnClick" IsEnabled="False"/>
                    </Grid>
                </Grid>
            </controls:PivotItem>

            <!--枢轴项二-->
            <controls:PivotItem>
                <controls:PivotItem.Header>
                    <TextBlock Text="TIMER" Style="{StaticResource PivotHeader}"/>
                </controls:PivotItem.Header>
                <Grid x:Name="TimerPanel">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="200"/>
                    </Grid.RowDefinitions>
                    <swControls:TimerControl Grid.Row="0" x:Name="timerControl" Height="400" Width="440" VerticalAlignment="Center" />
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="15"/>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="timerReset" Grid.Column="1" Margin="8" Content="reset" VerticalAlignment="Bottom" Template="{StaticResource resetButton}" Click="TimerResetOnClick" IsEnabled="False" />
                        <Button x:Name="timerStart" Grid.Column="3" Margin="5" Content="start" VerticalAlignment="Bottom" Template="{StaticResource startButton}" Click="TimerStartOnClick" />
                        <Button x:Name="timerPause" Grid.Column="3" Margin="5" Content="pause" VerticalAlignment="Bottom" Template="{StaticResource pauseButton}" Click="TimerStartOnClick" Visibility="Collapsed"/>
                    </Grid>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Themes/Images/info.png" Text="about" Click="AboutOnClick"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>